/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package entities;

import java.io.Serializable;
import java.math.BigInteger;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Alejandro
 */
@Entity
@Table(name = "SILLA")
@NamedQueries({
    @NamedQuery(name = "Silla.findAll", query = "SELECT s FROM Silla s")})
public class Silla implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected SillaPK sillaPK;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "silla")
    private List<Sillaxpartido> sillaxpartidoList;
    @JoinColumns({
        @JoinColumn(name = "CATEGORIA_ID_CATEGORIA", referencedColumnName = "ID_CATEGORIA", insertable = false, updatable = false),
        @JoinColumn(name = "CATEGORIA_ESTADIO_ID_ESTADIO", referencedColumnName = "ESTADIO_ID_ESTADIO", insertable = false, updatable = false)})
    @ManyToOne(optional = false)
    private Categoria categoria;

    public Silla() {
    }

    public Silla(SillaPK sillaPK) {
        this.sillaPK = sillaPK;
    }

    public Silla(BigInteger numeroFila, BigInteger numeroAsiento, BigInteger categoriaIdCategoria, BigInteger categoriaEstadioIdEstadio) {
        this.sillaPK = new SillaPK(numeroFila, numeroAsiento, categoriaIdCategoria, categoriaEstadioIdEstadio);
    }

    public SillaPK getSillaPK() {
        return sillaPK;
    }

    public void setSillaPK(SillaPK sillaPK) {
        this.sillaPK = sillaPK;
    }

    public List<Sillaxpartido> getSillaxpartidoList() {
        return sillaxpartidoList;
    }

    public void setSillaxpartidoList(List<Sillaxpartido> sillaxpartidoList) {
        this.sillaxpartidoList = sillaxpartidoList;
    }

    public Categoria getCategoria() {
        return categoria;
    }

    public void setCategoria(Categoria categoria) {
        this.categoria = categoria;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (sillaPK != null ? sillaPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Silla)) {
            return false;
        }
        Silla other = (Silla) object;
        if ((this.sillaPK == null && other.sillaPK != null) || (this.sillaPK != null && !this.sillaPK.equals(other.sillaPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.Silla[ sillaPK=" + sillaPK + " ]";
    }
    
}
